//
//  RTLineTextField.m
//  StoryToy
//
//  Created by baxiang on 2017/11/7.
//  Copyright © 2017年 roobo. All rights reserved.
//

#import "RTLineTextField.h"
@interface RTLineTextField()

@end
@implementation RTLineTextField

- (void)drawRect:(CGRect)rect {
     CGContextRef context = UIGraphicsGetCurrentContext();
    if (self.isFirstResponder) {
         CGContextSetFillColorWithColor(context, RTColorForBackground.CGColor);
    }else{
         CGContextSetFillColorWithColor(context, UIColorHex(0xdddddd).CGColor);
    }
    CGContextFillRect(context, CGRectMake(0, CGRectGetHeight(self.frame) - 1, CGRectGetWidth(self.frame), 1));
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
    
     [self setNeedsDisplay];
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
     [self setNeedsDisplay];
    return YES;
}
@end
